package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author Feng
 * @date 2023/4/27
 */
@Getter
@AllArgsConstructor
public enum EquipmentPositionType {
    ROOM_HOUSE(1,"房源"),
    STORE_ROOM(2,"库房"),
    PUB_PlACE(3,"公区");

    private int code;
    private String name;


    public static String getNameByCode(String code) {
        if (StrUtil.isEmpty(code)) {
            return null;
        }
        Optional<EquipmentPositionType> find = Arrays.stream(EquipmentPositionType.values()).filter(s -> ((s.getCode()+"").equals(code))).findFirst();
        if (find.isPresent()) {
            return find.get().getName();
        }
        return null;
    }
}
